package com.smyh.method;

import com.smyh.UIM.record.HostSyncRecordFm;
import com.smyh.cache.UIM.HostSyncRecordUI;
import com.smyh.cache.UIM.right.host.wave_record.FaultRecordCache;
import com.smyh.common.MinaClientThread;
import com.smyh.protcol.device.CMDUtil;
import com.smyh.server.ToastShowMsgThread;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;

public class WaveRecordMethod {

	/**
	 * 指示器读取单波：电流-电压
	 */
	public static void readSingleWave_D9Wave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xd9;
			IoBuffer buf = CMDUtil.readWaveData(type);
			session.write(buf);
		}
	}
	
	public static void readDCWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xdc;
			IoBuffer buf = CMDUtil.readWaveData(type);
			session.write(buf);
		}
	}
	public static void readDDWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xdd;
			IoBuffer buf = CMDUtil.readWaveData(type);
			session.write(buf);
		}
	}
	public static void readDEWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xde;
			IoBuffer buf = CMDUtil.readWaveData(type);
			session.write(buf);
		}
	}
	public static void readDFWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xdf;
			IoBuffer buf = CMDUtil.readWaveData(type);
			session.write(buf);
		}
	}
	
	/**
	 * 通讯主机读取同步录波电流
	 */
	public static void readECWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xec;
			int counts = HostSyncRecordFm.checkContentIndex;
			int groupNum = HostSyncRecordUI.chooseGroup;
			int phase = HostSyncRecordUI.choosePhase;
			IoBuffer buf = CMDUtil.readHostWaveData(type, (byte)counts, (byte)groupNum, (byte)phase);
			session.write(buf);
		}
	}

	/**
	 * 通讯主机读取同步录波电流
	 */
	public static void readEDWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xed;
			int counts = HostSyncRecordFm.checkContentIndex;
			int groupNum = HostSyncRecordUI.chooseGroup;
			int phase = HostSyncRecordUI.choosePhase;
			IoBuffer buf = CMDUtil.readHostWaveData(type, (byte)counts, (byte)groupNum, (byte)phase);
			session.write(buf);
		}
	}

	/**
	 * 通讯主机读取同步录波电流
	 */
	public static void readEEWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xee;
			int counts = FaultRecordCache.getEEIndex();
			int groupNum = FaultRecordCache.getEEgroupNum();
			int phase = FaultRecordCache.getEEphase();
			IoBuffer buf = CMDUtil.readHostWaveData(type, (byte)counts, (byte)groupNum, (byte)phase);
			session.write(buf);
		}
	}

	/**
	 * 通讯主机读取同步录波电流
	 */
	public static void readEFWave(){
		IoSession session = MinaClientThread.session;
		if(session == null){
			new Thread(new ToastShowMsgThread("通讯断开，请检查!")).start();
		}else{
			byte type = (byte) 0xef;
			int counts = FaultRecordCache.getEFIndex();
			int groupNum = FaultRecordCache.getEFgroupNum();
			int phase = FaultRecordCache.getEFphase();
			IoBuffer buf = CMDUtil.readHostWaveData(type, (byte)counts, (byte)groupNum, (byte)phase);
			session.write(buf);
		}
	}

}
